<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;


use App\Utils\OSS\OssClient;
use App\Utils\OSS\Core\OssException;

class DisCourseClass extends Model
{
	protected $table = 'dis_course_class';
    //
    public function dataStore($data){
    	return $this->insert($data);
    }
    public function getList(){
    	$data = $this->orderBy("id","desc")->paginate(10);
    	return $data;
    }
    /**
     * 更新
     */
    public function updateData($id,$data){
    	return $this->where("id",$id)->update($data);
    }

    public function deleteVideo($object){
        $accessKeyId = "LTAIJPXZ5xRBpkJJ";
        $accessKeySecret = "cRUMuvKyH3TJ2010f9bo9P2CyZpgkI";
        $endpoint = "http://oss-cn-beijing.aliyuncs.com";
        $bucket= "saipujianshenbbs";
        $object = $object;
        try{
            $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
            $ossClient->deleteObject($bucket, $object);
        } catch(OssException $e) {
            printf(__FUNCTION__ . ": FAILED\n");
            printf($e->getMessage() . "\n");
            return;
        }
        //print(__FUNCTION__ . ": OK" . "\n");
        return true;
    }
    public function deleteData($id){
        $re = $this->where('id',$id)->delete();
        return $re;
    }
	
}
